#include "stdafx.h"
#include "SinhVien.h"
#include "Comparable.h"
#pragma once;

template<class T, class L>
class SV_Order:public Comparable<T>
{
protected:
	bool order;
	L (T::*p)();
public:
	SV_Order(bool order, L (T::*funcPtr)())
	{
		this->order = order;
		p =  funcPtr;
	}
	SV_Order()
	{
		this->order = ASCEND;
	}
	void addComparable(Comparable* cp)
	{

	}
	int compare(const T& a, const T& b)
	{
		SinhVien svA = a;
		SinhVien svB = b;

		if((svA.*p)() > (svB.*p)())
			return (order == ASCEND ? TRUE : FALSE);
		else if((svA.*p)() < (svB.*p)())
			return (order == DESCEND ? TRUE : FALSE);

		return EQUAL;

	}
};

template<class T>
class SV_DiemTrungBinh_Order:public Comparable<T>
{
protected:
	bool order;
public:
	SV_DiemTrungBinh_Order(bool order)
	{
		this->order = order;
	}
	SV_DiemTrungBinh_Order()
	{
		this->order = ASCEND;
	}
	void addComparable(Comparable* cp)
	{

	}
	int compare(const T& a, const T& b)
	{
		SinhVien svA = a;
		SinhVien svB = b;

		if(svA.getDiemTrungBinh() > svB.getDiemTrungBinh())
			return (order == ASCEND ? TRUE : FALSE);
		else if(svA.getDiemTrungBinh() < svB.getDiemTrungBinh())
			return (order == DESCEND ? TRUE : FALSE);

		return EQUAL;
	}
};
